package com.informationsystem.webapp.action;

import java.util.List;

import com.informationsystem.model.Event;
import com.informationsystem.service.EventManager;

public class InfoCenter_Event_Action extends BaseAction {
	private EventManager eventManager;
	private List eventList;
	private Event event;
	private Long id;

	public EventManager getEventManager() {
		return eventManager;
	}

	public void setEventManager(EventManager eventManager) {
		this.eventManager = eventManager;
	}

	public List getEventList() {
		return eventList;
	}

	public void setEventList(List eventList) {
		this.eventList = eventList;
	}

	public Event getEvent() {
		return event;
	}

	public void setEvent(Event event) {
		this.event = event;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String list() {
		setEventList(eventManager.getEventList());
		return SUCCESS;
	}

	public String view() {
		if (getId() != null) {
			setEvent(eventManager.get(getId()));
			event.setViewTimes(event.getViewTimes() + 1);
			eventManager.save(event);
		} else {
			setEvent(new Event());
		}

		return SUCCESS;
	}
}
